newbie in c and issue with integers [migrated]

Posted by user2527918 on Programmers See other posts from Programmers or by user2527918
Published on 2013-06-27T11:47:30Z Indexed on 2013/06/27 16:28 UTC
Read the original article Hit count: 200

Filed under:
//
//  main.c
//  cmd4
//
//  Created by Kevin Rudd on 27/06/13.
//  Copyright (c) 2013 Charlie Brown. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[])
{
  int x =10, y =20, b = 500;
  int z = x*y;
  int f = z/b;

  // insert code here...
  printf("x is:%d, y is:%d, b is %d\n",x,y,b);
  printf("x times y is: %d\n",z);
  printf("z divided by b is: %d\n",f);
  return 0;
}

on print out f = 0. Why?

© Programmers or respective owner

Related posts about c